const colorNames = new Set<string>();
type Suggestion1 = Fig.Modify<Fig.Suggestion, { name: string }>;
let foregroundSuggestions: Suggestion1[];
let backgroundSuggestions: Suggestion1[];
let foregroundSuggestionsColor: Suggestion1[];
let backgroundSuggestionsColor: Suggestion1[];
{
  const colorSuggestions: Suggestion1[] = [
    {
      name: "black",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=000000",
    },
    {
      name: "red",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=8000000",
    },
    {
      name: "green",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=008000",
    },
    {
      name: "yellow",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=808000",
    },
    {
      name: "blue",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=000080",
    },
    {
      name: "magenta",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=800080",
    },
    {
      name: "cyan",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=008080",
    },
    {
      name: "white",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=c0c0c0",
    },
    {
      name: "bright_black",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=808080",
    },
    {
      name: "bright_red",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=ff0000",
    },
    {
      name: "bright_green",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=00ff00",
    },
    {
      name: "bright_yellow",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=ffff00",
    },
    {
      name: "bright_blue",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=0000ff",
    },
    {
      name: "bright_magenta",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=ff00ff",
    },
    {
      name: "bright_cyan",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=00ffff",
    },
    {
      name: "bright_white",
      description: "Defined by terminal, appearance may differ",
      icon: "fig://template?color=ffffff",
    },
    { name: "grey0", icon: "fig://template?color=000000" },
    { name: "navy_blue", icon: "fig://template?color=00005f" },
    { name: "dark_blue", icon: "fig://template?color=000087" },
    { name: "blue3", icon: "fig://template?color=0000d7" },
    { name: "blue1", icon: "fig://template?color=0000ff" },
    { name: "dark_green", icon: "fig://template?color=005f00" },
    { name: "deep_sky_blue4", icon: "fig://template?color=005faf" },
    { name: "dodger_blue3", icon: "fig://template?color=005fd7" },
    { name: "dodger_blue2", icon: "fig://template?color=005fff" },
    { name: "green4", icon: "fig://template?color=008700" },
    { name: "spring_green4", icon: "fig://template?color=00875f" },
    { name: "turquoise4", icon: "fig://template?color=008787" },
    { name: "deep_sky_blue3", icon: "fig://template?color=0087d7" },
    { name: "dodger_blue1", icon: "fig://template?color=0087ff" },
    { name: "dark_cyan", icon: "fig://template?color=00af87" },
    { name: "light_sea_green", icon: "fig://template?color=00afaf" },
    { name: "deep_sky_blue2", icon: "fig://template?color=00afd7" },
    { name: "deep_sky_blue1", icon: "fig://template?color=00afff" },
    { name: "green3", icon: "fig://template?color=00d700" },
    { name: "spring_green3", icon: "fig://template?color=00d75f" },
    { name: "cyan3", icon: "fig://template?color=00d7af" },
    { name: "dark_turquoise", icon: "fig://template?color=00d7d7" },
    { name: "turquoise2", icon: "fig://template?color=00d7ff" },
    { name: "green1", icon: "fig://template?color=00ff00" },
    { name: "spring_green2", icon: "fig://template?color=00ff5f" },
    { name: "spring_green1", icon: "fig://template?color=00ff87" },
    { name: "medium_spring_green", icon: "fig://template?color=00ffaf" },
    { name: "cyan2", icon: "fig://template?color=00ffd7" },
    { name: "cyan1", icon: "fig://template?color=00ffff" },
    { name: "purple4", icon: "fig://template?color=5f00af" },
    { name: "purple3", icon: "fig://template?color=5f00d7" },
    { name: "blue_violet", icon: "fig://template?color=5f00ff" },
    { name: "grey37", icon: "fig://template?color=5f5f5f" },
    { name: "medium_purple4", icon: "fig://template?color=5f5f87" },
    { name: "slate_blue3", icon: "fig://template?color=5f5fd7" },
    { name: "royal_blue1", icon: "fig://template?color=5f5fff" },
    { name: "chartreuse4", icon: "fig://template?color=5f8700" },
    { name: "pale_turquoise4", icon: "fig://template?color=5f8787" },
    { name: "steel_blue", icon: "fig://template?color=5f87af" },
    { name: "steel_blue3", icon: "fig://template?color=5f87d7" },
    { name: "cornflower_blue", icon: "fig://template?color=5f87ff" },
    { name: "dark_sea_green4", icon: "fig://template?color=5faf5f" },
    { name: "cadet_blue", icon: "fig://template?color=5fafaf" },
    { name: "sky_blue3", icon: "fig://template?color=5fafd7" },
    { name: "chartreuse3", icon: "fig://template?color=5fd700" },
    { name: "sea_green3", icon: "fig://template?color=5fd787" },
    { name: "aquamarine3", icon: "fig://template?color=5fd7af" },
    { name: "medium_turquoise", icon: "fig://template?color=5fd7d7" },
    { name: "steel_blue1", icon: "fig://template?color=5fd7ff" },
    { name: "sea_green2", icon: "fig://template?color=5fff5f" },
    { name: "sea_green1", icon: "fig://template?color=5fffaf" },
    { name: "dark_slate_gray2", icon: "fig://template?color=5fffff" },
    { name: "dark_red", icon: "fig://template?color=870000" },
    { name: "dark_magenta", icon: "fig://template?color=8700af" },
    { name: "orange4", icon: "fig://template?color=875f00" },
    { name: "light_pink4", icon: "fig://template?color=875f5f" },
    { name: "plum4", icon: "fig://template?color=875f87" },
    { name: "medium_purple3", icon: "fig://template?color=875fd7" },
    { name: "slate_blue1", icon: "fig://template?color=875fff" },
    { name: "wheat4", icon: "fig://template?color=87875f" },
    { name: "grey53", icon: "fig://template?color=878787" },
    { name: "light_slate_grey", icon: "fig://template?color=8787af" },
    { name: "medium_purple", icon: "fig://template?color=8787d7" },
    { name: "light_slate_blue", icon: "fig://template?color=8787ff" },
    { name: "yellow4", icon: "fig://template?color=87af00" },
    { name: "dark_sea_green", icon: "fig://template?color=87af87" },
    { name: "light_sky_blue3", icon: "fig://template?color=87afd7" },
    { name: "sky_blue2", icon: "fig://template?color=87afff" },
    { name: "chartreuse2", icon: "fig://template?color=87d700" },
    { name: "pale_green3", icon: "fig://template?color=87d787" },
    { name: "dark_slate_gray3", icon: "fig://template?color=87d7d7" },
    { name: "sky_blue1", icon: "fig://template?color=87d7ff" },
    { name: "chartreuse1", icon: "fig://template?color=87ff00" },
    { name: "light_green", icon: "fig://template?color=87ff87" },
    { name: "aquamarine1", icon: "fig://template?color=87ffd7" },
    { name: "dark_slate_gray1", icon: "fig://template?color=87ffff" },
    { name: "deep_pink4", icon: "fig://template?color=af005f" },
    { name: "medium_violet_red", icon: "fig://template?color=af0087" },
    { name: "dark_violet", icon: "fig://template?color=af00d7" },
    { name: "purple", icon: "fig://template?color=af00ff" },
    { name: "medium_orchid3", icon: "fig://template?color=af5faf" },
    { name: "medium_orchid", icon: "fig://template?color=af5fd7" },
    { name: "dark_goldenrod", icon: "fig://template?color=af8700" },
    { name: "rosy_brown", icon: "fig://template?color=af8787" },
    { name: "grey63", icon: "fig://template?color=af87af" },
    { name: "medium_purple2", icon: "fig://template?color=af87d7" },
    { name: "medium_purple1", icon: "fig://template?color=af87ff" },
    { name: "dark_khaki", icon: "fig://template?color=afaf5f" },
    { name: "navajo_white3", icon: "fig://template?color=afaf87" },
    { name: "grey69", icon: "fig://template?color=afafaf" },
    { name: "light_steel_blue3", icon: "fig://template?color=afafd7" },
    { name: "light_steel_blue", icon: "fig://template?color=afafff" },
    { name: "dark_olive_green3", icon: "fig://template?color=afd75f" },
    { name: "dark_sea_green3", icon: "fig://template?color=afd787" },
    { name: "light_cyan3", icon: "fig://template?color=afd7d7" },
    { name: "light_sky_blue1", icon: "fig://template?color=afd7ff" },
    { name: "green_yellow", icon: "fig://template?color=afff00" },
    { name: "dark_olive_green2", icon: "fig://template?color=afff5f" },
    { name: "pale_green1", icon: "fig://template?color=afff87" },
    { name: "dark_sea_green2", icon: "fig://template?color=afffaf" },
    { name: "pale_turquoise1", icon: "fig://template?color=afffff" },
    { name: "red3", icon: "fig://template?color=d70000" },
    { name: "deep_pink3", icon: "fig://template?color=d70087" },
    { name: "magenta3", icon: "fig://template?color=d700d7" },
    { name: "dark_orange3", icon: "fig://template?color=d75f00" },
    { name: "indian_red", icon: "fig://template?color=d75f5f" },
    { name: "hot_pink3", icon: "fig://template?color=d75f87" },
    { name: "hot_pink2", icon: "fig://template?color=d75faf" },
    { name: "orchid", icon: "fig://template?color=d75fd7" },
    { name: "orange3", icon: "fig://template?color=d78700" },
    { name: "light_salmon3", icon: "fig://template?color=d7875f" },
    { name: "light_pink3", icon: "fig://template?color=d78787" },
    { name: "pink3", icon: "fig://template?color=d787af" },
    { name: "plum3", icon: "fig://template?color=d787d7" },
    { name: "violet", icon: "fig://template?color=d787ff" },
    { name: "gold3", icon: "fig://template?color=d7af00" },
    { name: "light_goldenrod3", icon: "fig://template?color=d7af5f" },
    { name: "tan", icon: "fig://template?color=d7af87" },
    { name: "misty_rose3", icon: "fig://template?color=d7afaf" },
    { name: "thistle3", icon: "fig://template?color=d7afd7" },
    { name: "plum2", icon: "fig://template?color=d7afff" },
    { name: "yellow3", icon: "fig://template?color=d7d700" },
    { name: "khaki3", icon: "fig://template?color=d7d75f" },
    { name: "light_yellow3", icon: "fig://template?color=d7d7af" },
    { name: "grey84", icon: "fig://template?color=d7d7d7" },
    { name: "light_steel_blue1", icon: "fig://template?color=d7d7ff" },
    { name: "yellow2", icon: "fig://template?color=d7ff00" },
    { name: "dark_olive_green1", icon: "fig://template?color=d7ff87" },
    { name: "dark_sea_green1", icon: "fig://template?color=d7ffaf" },
    { name: "honeydew2", icon: "fig://template?color=d7ffd7" },
    { name: "light_cyan1", icon: "fig://template?color=d7ffff" },
    { name: "red1", icon: "fig://template?color=ff0000" },
    { name: "deep_pink2", icon: "fig://template?color=ff005f" },
    { name: "deep_pink1", icon: "fig://template?color=ff00af" },
    { name: "magenta2", icon: "fig://template?color=ff00d7" },
    { name: "magenta1", icon: "fig://template?color=ff00ff" },
    { name: "orange_red1", icon: "fig://template?color=ff5f00" },
    { name: "indian_red1", icon: "fig://template?color=ff5f87" },
    { name: "hot_pink", icon: "fig://template?color=ff5fd7" },
    { name: "medium_orchid1", icon: "fig://template?color=ff5fff" },
    { name: "dark_orange", icon: "fig://template?color=ff8700" },
    { name: "salmon1", icon: "fig://template?color=ff875f" },
    { name: "light_coral", icon: "fig://template?color=ff8787" },
    { name: "pale_violet_red1", icon: "fig://template?color=ff87af" },
    { name: "orchid2", icon: "fig://template?color=ff87d7" },
    { name: "orchid1", icon: "fig://template?color=ff87ff" },
    { name: "orange1", icon: "fig://template?color=ffaf00" },
    { name: "sandy_brown", icon: "fig://template?color=ffaf5f" },
    { name: "light_salmon1", icon: "fig://template?color=ffaf87" },
    { name: "light_pink1", icon: "fig://template?color=ffafaf" },
    { name: "pink1", icon: "fig://template?color=ffafd7" },
    { name: "plum1", icon: "fig://template?color=ffafff" },
    { name: "gold1", icon: "fig://template?color=ffd700" },
    { name: "light_goldenrod2", icon: "fig://template?color=ffd787" },
    { name: "navajo_white1", icon: "fig://template?color=ffd7af" },
    { name: "misty_rose1", icon: "fig://template?color=ffd7d7" },
    { name: "thistle1", icon: "fig://template?color=ffd7ff" },
    { name: "yellow1", icon: "fig://template?color=ffff00" },
    { name: "light_goldenrod1", icon: "fig://template?color=ffff5f" },
    { name: "khaki1", icon: "fig://template?color=ffff87" },
    { name: "wheat1", icon: "fig://template?color=ffffaf" },
    { name: "cornsilk1", icon: "fig://template?color=ffffd7" },
    { name: "grey100", icon: "fig://template?color=ffffff" },
    { name: "grey3", icon: "fig://template?color=080808" },
    { name: "grey7", icon: "fig://template?color=121212" },
    { name: "grey11", icon: "fig://template?color=1c1c1c" },
    { name: "grey15", icon: "fig://template?color=262626" },
    { name: "grey19", icon: "fig://template?color=303030" },
    { name: "grey23", icon: "fig://template?color=3a3a3a" },
    { name: "grey27", icon: "fig://template?color=444444" },
    { name: "grey30", icon: "fig://template?color=4e4e4e" },
    { name: "grey35", icon: "fig://template?color=585858" },
    { name: "grey39", icon: "fig://template?color=626262" },
    { name: "grey42", icon: "fig://template?color=6c6c6c" },
    { name: "grey46", icon: "fig://template?color=767676" },
    { name: "grey50", icon: "fig://template?color=808080" },
    { name: "grey54", icon: "fig://template?color=8a8a8a" },
    { name: "grey58", icon: "fig://template?color=949494" },
    { name: "grey62", icon: "fig://template?color=9e9e9e" },
    { name: "grey66", icon: "fig://template?color=a8a8a8" },
    { name: "grey70", icon: "fig://template?color=b2b2b2" },
    { name: "grey74", icon: "fig://template?color=bcbcbc" },
    { name: "grey78", icon: "fig://template?color=c6c6c6" },
    { name: "grey82", icon: "fig://template?color=d0d0d0" },
    { name: "grey85", icon: "fig://template?color=dadada" },
    { name: "grey89", icon: "fig://template?color=e4e4e4" },
    { name: "grey93", icon: "fig://template?color=eeeeee" },
  ];

  for (const { name } of colorSuggestions) {
    colorNames.add(name);
  }

  const styleSuggestions: Suggestion1[] = [
    { name: "bold" },
    { name: "blink" },
    { name: "blink2" },
    { name: "conceal" },
    { name: "italic" },
    { name: "reverse" },
    { name: "strike" },
    { name: "underline" },
    { name: "underline2", description: "Not well supported" },
    { name: "frame", description: "Not well supported" },
    { name: "encircle", description: "Not well supported" },
    { name: "overline", description: "Not well supported" },
  ];

  foregroundSuggestions = [
    ...styleSuggestions,
    {
      name: "on",
      description: "Style the background",
    },
    { name: "default", description: "Use the default foreground style" },
  ];

  foregroundSuggestionsColor = [...foregroundSuggestions, ...colorSuggestions];

  backgroundSuggestions = [
    { name: "default", description: "Use the default foreground style" },
  ];

  backgroundSuggestionsColor = [...backgroundSuggestions, ...colorSuggestions];
}

const styleGenerator: Fig.Generator = {
  trigger: " ",
  getQueryTerm: " ",
  custom: async (tokens) => {
    const finalToken = tokens[tokens.length - 1];
    const styleTokens = finalToken.trim().split(" ");
    const seen = new Set(styleTokens);
    let suggestions: Suggestion1[];
    if (!seen.has("on")) {
      const suggestColors = !styleTokens.some((token) => colorNames.has(token));
      suggestions = suggestColors
        ? foregroundSuggestionsColor
        : foregroundSuggestions;
    } else {
      const bgTokens = styleTokens.slice(styleTokens.indexOf("on"));
      const suggestColors = !bgTokens.some((token) => colorNames.has(token));
      suggestions = suggestColors
        ? backgroundSuggestionsColor
        : backgroundSuggestions;
    }
    return suggestions.filter(({ name }) => !seen.has(name));
  },
};

type MaybeString = string | undefined;

const pad = (string: MaybeString) => {
  if (!string) {
    return "?";
  }
  if (Number.isNaN(Number(string))) {
    return `${string}(!)`;
  }
  return string;
};

const paddingDisplayName = (
  ...args: [
    top: MaybeString,
    right: MaybeString,
    bottom: MaybeString,
    left: MaybeString,
  ]
) => {
  const [top, right, bottom, left] = args.map((string) => pad(string));
  return `Top: ${top}, right: ${right}, bottom: ${bottom}, left: ${left}`;
};

const completionSpec: Fig.Spec = {
  name: "rich",
  description: "Rich text and formatting in the terminal",
  args: {
    name: "path/text/url",
    suggestions: [{ name: "-", description: "Read from stdin", hidden: true }],
    template: "filepaths",
  },
  options: [
    {
      name: ["-p", "--print"],
      description:
        "Print console markup. See https://rich.readthedocs.io/en/latest/markup.html",
    },
    { name: ["-u", "--rule"], description: "Display a horizontal rule" },
    { name: ["-j", "--json"], description: "Display as JSON" },
    { name: ["-m", "--markdown"], description: "Display as markdown" },
    { name: "--rst", description: "Display restructured text" },
    { name: "--csv", description: "Display CSV as a table" },
    { name: "--ipynb", description: "Display Jupyter notebook" },
    { name: "--syntax", description: "Syntax highlighting" },
    { name: "--inspect", description: "Inspect a python object" },
    {
      name: ["-h", "--head"],
      args: { name: "lines" },
      description: "Display first LINES of the file",
      // NOTE: there's no way to specify (--syntax OR --csv), only both.
      // However, the implementation of dependsOn boosts the priority of all
      // dependencies which means it's okay regardless.
      dependsOn: ["--syntax", "--csv"],
    },
    {
      name: ["-t", "--tail"],
      args: { name: "lines" },
      description: "Display last LINES of the file",
      dependsOn: ["--syntax", "--csv"],
    },
    {
      // NOTE: Commenting out because of the duplicate name, -j
      // name: ["-j", "--emoji"],
      name: "--emoji",
      description: "Enable emoji code. e.g. :sparkle:",
    },
    { name: ["-l", "--left"], description: "Align to left" },
    { name: ["-r", "--right"], description: "Align to right" },
    { name: ["-c", "--center"], description: "Align to center" },
    { name: ["-L", "--text-left"], description: "Justify text to left" },
    { name: ["-R", "--text-right"], description: "Justify text to right" },
    { name: ["-C", "--text-center"], description: "Justify text to center" },
    {
      name: ["-F", "--text-full"],
      description: "Justify text to both left and right edges",
    },
    {
      name: "--soft",
      description: "Enable soft wrapping of text",
      dependsOn: ["--print"],
    },
    {
      name: ["-e", "--expand"],
      description: "Expand to full width",
      dependsOn: ["--panel"],
    },
    {
      name: ["-w", "--width"],
      args: { name: "size" },
      description: "Fit output to SIZE characters",
    },
    {
      name: ["-W", "--max-width"],
      args: { name: "size" },
      description: "Set maximum width to SIZE characters",
    },
    {
      name: ["-s", "--style"],
      args: {
        name: "style",
        generators: styleGenerator,
        filterStrategy: "fuzzy",
      },
      description: "Set text style to STYLE",
    },
    {
      name: "--rule-style",
      args: {
        name: "style",
        generators: styleGenerator,
        filterStrategy: "fuzzy",
      },
      description: "Set rule style to STYLE",
      dependsOn: ["--rule"],
    },
    {
      name: "--rule-char",
      args: { name: "character" },
      description: "Use CHARACTER to generate a line with --rule",
      dependsOn: ["--rule"],
    },
    {
      name: ["-d", "--padding"],
      args: {
        name: "top,right,bottom,left",
        generators: {
          // Needs to trigger on each character to suggest the current token
          trigger: () => true,
          custom: async (tokens) => {
            const finalToken = tokens[tokens.length - 1];
            if (finalToken === "" || finalToken === "-d") {
              return [];
            }
            const parts = finalToken.split(",");
            const numberOfParts = parts.length;
            let description: string | undefined;
            switch (numberOfParts) {
              case 1: {
                const [p] = parts;
                description = paddingDisplayName(p, p, p, p);
                break;
              }
              case 2: {
                const [v, h] = parts;
                description = paddingDisplayName(v, h, v, h);
                break;
              }
              case 3:
              case 4:
                const [t, r, l, b = ""] = parts;
                description = paddingDisplayName(t, r, l, b);
                break;
            }
            return [{ name: finalToken, description }];
          },
        },
      },
      description:
        "Padding around output. 1, 2 or 4 comma separated integers, e.g. 2,4",
    },
    {
      name: ["-a", "--panel"],
      args: {
        name: "box",
        suggestions: [
          "ascii",
          "ascii2",
          "double",
          "heavy",
          "none",
          "rounded",
          "square",
        ],
      },
      description: "Set panel type to BOX",
    },
    {
      name: ["-S", "--panel-style"],
      args: {
        name: "style",
        generators: styleGenerator,
        filterStrategy: "fuzzy",
      },
      description: "Set the panel style to STYLE",
      dependsOn: ["--panel"],
    },
    {
      name: "--theme",
      args: {
        name: "theme",
        filterStrategy: "fuzzy",
        suggestions: [
          "default",
          "bw",
          "sas",
          "staroffice",
          "xcode",
          "github-dark",
          "rrt",
          "abap",
          "algol",
          "algol_nu",
          "arduino",
          "autumn",
          "borland",
          "colorful",
          "igor",
          "lovelace",
          "murphy",
          "pastie",
          "rainbow_dash",
          "stata",
          "stata-light",
          "trac",
          "vs",
          "emacs",
          "tango",
          "solarized-light",
          "manni",
          "gruvbox-light",
          "friendly",
          "friendly_grayscale",
          "perldoc",
          "paraiso-light",
          "zenburn",
          "nord",
          "material",
          "one-dark",
          "dracula",
          "nord-darker",
          "gruvbox-dark",
          "monokai",
          "stata-dark",
          "paraiso-dark",
          "solarized-dark",
          "native",
          "inkpot",
          "fruity",
          "vim",
        ],
      },
      description:
        "Set syntax theme to THEME. See https://pygments.org/styles/",
    },
    {
      name: ["-n", "--line-numbers"],
      description: "Enable line number in syntax",
    },
    {
      name: ["-g", "--guides"],
      description: "Enable indentation guides in syntax highlighting",
    },
    {
      // TODO: scrape lexers page for the suggestions
      name: ["-x", "--lexer"],
      args: {
        name: "lexer",
        filterStrategy: "fuzzy",
        suggestions: [
          "ActionScript3",
          "ActionScript",
          "Mxml",
          "Ada",
          "BC",
          "GAPConsole",
          "GAP",
          "Mathematica",
          "MuPAD",
          "AmbientTalk",
          "AMDGPU",
          "Ampl",
          "apdlexer",
          "APL",
          "Adl",
          "Cadl",
          "Odin",
          "Arrow",
          "Asc",
          "CObjdump",
          "Ca65",
          "CppObjdump",
          "DObjdump",
          "Dasm16",
          "Gas",
          "Hsail",
          "Llvm",
          "LlvmMirBody",
          "LlvmMir",
          "Nasm",
          "NasmObjdump",
          "Objdump",
          "Tasm",
          "AutoIt",
          "Autohotkey",
          "Bare",
          "BBCBasic",
          "BlitzBasic",
          "BlitzMax",
          "CbmBasicV2",
          "Monkey",
          "QBasic",
          "VBScript",
          "Bdd",
          "Berry",
          "BST",
          "BibTeX",
          "Boa",
          "ABAP",
          "CobolFreeformat",
          "Cobol",
          "GoodDataCL",
          "Maql",
          "OpenEdge",
          "C",
          "Cpp",
          "Arduino",
          "Charmci",
          "Clay",
          "Cuda",
          "EC",
          "Mql",
          "NesC",
          "OmgIdl",
          "Pike",
          "Swig",
          "Vala",
          "CapnProto",
          "Cddl",
          "Chapel",
          "Clean",
          "Comal80",
          "ApacheConf",
          "Augeas",
          "Cfengine3",
          "Docker",
          "Ini",
          "Kconfig",
          "LighttpdConf",
          "NestedText",
          "NginxConf",
          "PacmanConf",
          "PkgConfig",
          "Properties",
          "Regedit",
          "Singularity",
          "SquidConf",
          "TOML",
          "Termcap",
          "Terminfo",
          "Terraform",
          "UnixConfig",
          "PyPyLog",
          "VCTreeStatus",
          "Cplint",
          "Crystal",
          "CsoundDocument",
          "CsoundOrchestra",
          "CsoundScore",
          "Css",
          "LessCss",
          "Sass",
          "Scss",
          "Croc",
          "D",
          "MiniD",
          "Smali",
          "JsonBareObject",
          "JsonLd",
          "Json",
          "Yaml",
          "Devicetree",
          "DarcsPatch",
          "Diff",
          "WDiff",
          "Boo",
          "CSharpAspx",
          "CSharp",
          "FSharp",
          "Nemerle",
          "VbNetAspx",
          "VbNet",
          "Alloy",
          "Crmsh",
          "Flatline",
          "Mscgen",
          "Pan",
          "ProtoBuf",
          "Puppet",
          "Rsl",
          "Snowball",
          "Thrift",
          "VGL",
          "Zeek",
          "DylanConsole",
          "Dylan",
          "DylanLid",
          "ECL",
          "Eiffel",
          "Elm",
          "Elpi",
          "Email",
          "ElixirConsole",
          "Elixir",
          "Erlang",
          "ErlangShell",
          "Aheui",
          "Befunge",
          "Brainfuck",
          "CAmkES",
          "CapDL",
          "Redcode",
          "Ezhil",
          "Factor",
          "Fantom",
          "Felix",
          "FloScript",
          "Forth",
          "FortranFixed",
          "Fortran",
          "FoxPro",
          "FreeFem",
          "Futhark",
          "Gcode",
          "GDScript",
          "Go",
          "Abnf",
          "Bnf",
          "Jsgf",
          "Peg",
          "Cypher",
          "Asymptote",
          "GLShader",
          "Gnuplot",
          "HLSLShader",
          "PostScript",
          "Povray",
          "Graphviz",
          "GSQL",
          "Agda",
          "Cryptol",
          "Haskell",
          "Hspec",
          "Idris",
          "Koka",
          "LiterateAgda",
          "LiterateCryptol",
          "LiterateHaskell",
          "LiterateIdris",
          "Haxe",
          "Hxml",
          "SystemVerilog",
          "Verilog",
          "Vhdl",
          "Hexdump",
          "Dtd",
          "Haml",
          "Html",
          "Pug",
          "Scaml",
          "Xml",
          "Xslt",
          "IDL",
          "Igor",
          "Limbo",
          "DebianControl",
          "NSIS",
          "RPMSpec",
          "SourcesList",
          "Inform6",
          "Inform6Template",
          "Inform7",
          "Tads3",
          "Io",
          "J",
          "CoffeeScript",
          "Dart",
          "EarlGrey",
          "Javascript",
          "Juttle",
          "Kal",
          "Lasso",
          "LiveScript",
          "Mask",
          "NodeConsole",
          "ObjectiveJ",
          "TypeScript",
          "JMESPath",
          "JSLT",
          "JuliaConsole",
          "Julia",
          "AspectJ",
          "Ceylon",
          "Clojure",
          "ClojureScript",
          "Golo",
          "Gosu",
          "GosuTemplate",
          "Groovy",
          "Ioke",
          "Jasmin",
          "Java",
          "Kotlin",
          "Pig",
          "Sarl",
          "Scala",
          "Xtend",
          "Kuin",
          "LilyPond",
          "CPSA",
          "CommonLisp",
          "EmacsLisp",
          "Fennel",
          "Hy",
          "NewLisp",
          "Racket",
          "Scheme",
          "Shen",
          "Xtlang",
          "Macaulay2",
          "BaseMakefile",
          "CMake",
          "Makefile",
          "BBCode",
          "Groff",
          "Markdown",
          "MoinWiki",
          "MozPreprocCss",
          "MozPreprocHash",
          "MozPreprocJavascript",
          "MozPreprocPercent",
          "MozPreprocXul",
          "Rst",
          "Tex",
          "TiddlyWiki5",
          "Matlab",
          "MatlabSession",
          "Octave",
          "Scilab",
          "Maxima",
          "MCFunction",
          "SNBT",
          "Meson",
          "MIME",
          "FStar",
          "Ocaml",
          "Opa",
          "Reason",
          "SML",
          "Bugs",
          "Jags",
          "Modelica",
          "Stan",
          "Modula2",
          "Monte",
          "Mosel",
          "NCL",
          "Nimrod",
          "Nit",
          "Nix",
          "ComponentPascal",
          "Logos",
          "ObjectiveC",
          "ObjectiveCpp",
          "Swift",
          "Ooc",
          "ParaSail",
          "AntlrActionScript",
          "AntlrCSharp",
          "AntlrCpp",
          "AntlrJava",
          "Antlr",
          "AntlrObjectiveC",
          "AntlrPerl",
          "AntlrPython",
          "AntlrRuby",
          "Ebnf",
          "RagelC",
          "RagelCpp",
          "RagelD",
          "RagelEmbedded",
          "RagelJava",
          "Ragel",
          "RagelObjectiveC",
          "RagelRuby",
          "Treetop",
          "Delphi",
          "Pawn",
          "SourcePawn",
          "Perl6",
          "Perl",
          "Php",
          "PsyshConsole",
          "Zephir",
          "Pointless",
          "Pony",
          "Praat",
          "Procfile",
          "Logtalk",
          "Prolog",
          "PromQL",
          "Cython",
          "Dg",
          "NumPy",
          "Python2",
          "Python2Traceback",
          "PythonConsole",
          "Python",
          "PythonTraceback",
          "K",
          "Q",
          "Qlik",
          "QVTo",
          "RConsole",
          "Rd",
          "S",
          "ShExC",
          "Sparql",
          "Turtle",
          "Rebol",
          "Red",
          "Resource",
          "Ride",
          "Rita",
          "RNCCompact",
          "RoboconfGraph",
          "RoboconfInstances",
          "RobotFramework",
          "Fancy",
          "RubyConsole",
          "Ruby",
          "Rust",
          "SAS",
          "Savi",
          "Scdoc",
          "AppleScript",
          "Chaiscript",
          "Easytrieve",
          "Hybris",
          "Jcl",
          "LSL",
          "Lua",
          "MOOCode",
          "MiniScript",
          "MoonScript",
          "Rexx",
          "SmartGameFormat",
          "Bash",
          "BashSession",
          "Batch",
          "Execline",
          "FishShell",
          "MSDOSSession",
          "PowerShell",
          "PowerShellSession",
          "SlurmBash",
          "Tcsh",
          "TcshSession",
          "Sieve",
          "Slash",
          "Newspeak",
          "Smalltalk",
          "Smithy",
          "NuSMV",
          "Snobol",
          "Solidity",
          "Sophia",
          "Output",
          "RawToken",
          "Text",
          "Spice",
          "MySql",
          "PlPgsql",
          "PostgresConsole",
          "Postgres",
          "Rql",
          "Sql",
          "SqliteConsole",
          "TransactSql",
          "Srcinfo",
          "Stata",
          "SuperCollider",
          "Tal",
          "Tcl",
          "Teal",
          "Angular2Html",
          "Angular2",
          "CheetahHtml",
          "CheetahJavascript",
          "Cheetah",
          "CheetahXml",
          "ColdfusionCFC",
          "ColdfusionHtml",
          "Coldfusion",
          "CssDjango",
          "CssErb",
          "CssGenshi",
          "CssPhp",
          "CssSmarty",
          "Django",
          "Erb",
          "EvoqueHtml",
          "Evoque",
          "EvoqueXml",
          "Genshi",
          "GenshiText",
          "HandlebarsHtml",
          "Handlebars",
          "HtmlDjango",
          "HtmlGenshi",
          "HtmlPhp",
          "HtmlSmarty",
          "JavascriptDjango",
          "JavascriptErb",
          "JavascriptGenshi",
          "JavascriptPhp",
          "JavascriptSmarty",
          "Jsp",
          "LassoCss",
          "LassoHtml",
          "LassoJavascript",
          "LassoXml",
          "Liquid",
          "MakoCss",
          "MakoHtml",
          "MakoJavascript",
          "Mako",
          "MakoXml",
          "Mason",
          "MyghtyCss",
          "MyghtyHtml",
          "MyghtyJavascript",
          "Myghty",
          "MyghtyXml",
          "Rhtml",
          "Smarty",
          "SqlJinja",
          "Ssp",
          "TeaTemplate",
          "TwigHtml",
          "Twig",
          "VelocityHtml",
          "Velocity",
          "VelocityXml",
          "XmlDjango",
          "XmlErb",
          "XmlPhp",
          "XmlSmarty",
          "YamlJinja",
          "TeraTerm",
          "Gherkin",
          "TAP",
          "Awk",
          "Sed",
          "Vim",
          "Gettext",
          "Http",
          "IrcLogs",
          "KernelLog",
          "Notmuch",
          "Todotxt",
          "Coq",
          "Isabelle",
          "Lean",
          "ThingsDB",
          "TNT",
          "Rts",
          "TypoScriptCssData",
          "TypoScriptHtmlData",
          "TypoScript",
          "CSSUL4",
          "HTMLUL4",
          "JavascriptUL4",
          "PythonUL4",
          "UL4",
          "XMLUL4",
          "Icon",
          "Ucode",
          "Unicon",
          "Urbiscript",
          "Usd",
          "VCL",
          "VCLSnippet",
          "Boogie",
          "Silver",
          "Wat",
          "WebIDL",
          "Cirru",
          "Duel",
          "Qml",
          "Slim",
          "XQuery",
          "Whiley",
          "X10",
          "Xorg",
          "Yang",
          "Zig",
        ],
      },
      description:
        "Use LEXER for syntax highlighting. See https://pygments.org/docs/lexers/",
    },
    {
      name: ["-y", "--hyperlinks"],
      description: "Render hyperlinks in markdown",
    },
    {
      name: "--no-wrap",
      description: "Don't word wrap syntax highlighted files",
    },
    {
      name: "--title",
      args: { name: "text" },
      description: "Set panel title to TEXT",
    },
    {
      name: "--caption",
      args: { name: "text" },
      description: "Set panel caption to TEXT",
    },
    {
      name: "--force-terminal",
      description: "Force terminal output when not writing to a terminal",
    },
    {
      name: ["-o", "--export-html"],
      args: { name: "path", template: "filepaths", suggestCurrentToken: true },
      description: "Write HTML to PATH",
    },
    {
      name: "--export-svg",
      args: { name: "path", template: "filepaths", suggestCurrentToken: true },
      description: "Write SVG to PATH",
    },
    { name: "--pager", description: "Display in an interactive pager" },
    { name: ["-v", "--version"], description: "Print version and exit" },
    { name: "--help", description: "Show this message and exit" },
  ],
};

export default completionSpec;
